// $Id: compiler.hpp 2 2009-09-02 08:47:42Z joseph2002 $
/*
 * Copyright 2008 Joseph Wu
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 *
 * For more information, see http://xpcomplus.sourceforge.net
 */

#include <climits>

//
// Ensure that integer size is greater than or equals 16-bit
//
#if UINT_MAX < 0xFFFF
#  error 'sizeof(int)' not sufficient for platform use.
#endif

//
// We need new compilers...
//
#ifdef BOOST_NO_MEMBER_TEMPLATES
#  error xpcomplus library needs member templates, please use a newer compiler
#endif

#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#  error xpcomplus library needs template partial specialization, please use a newer compiler
#endif

#ifdef BOOST_NO_SFINAE
#  error xpcomplus library needs SFINAE, please use a newer compiler
#endif

//
// Compilers which supports '#pragma message()' or '#warning'
//
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
    defined(__DMC__) || defined(__MWERKS__)
#  define XPCOM_HAS_PRAGMA_MESSAGE
#endif

#if defined(__GNUC__) || defined(__HP_aCC) || \
    defined(__SUNPRO_CC) || defined(__IBMCPP__)
#  define XPCOM_HAS_WARNING_MESSAGE
#endif

#ifdef __EDG__
#  undef XPCOM_HAS_PRAGMA_MESSAGE
#  undef XPCOM_HAS_WARNING_MESSAGE
#endif

//
// Capabilities
//
// GCC 3.3 and later support the visibility attribute
// XXX This is from NSPR code
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
#  define XPCOM_HAS_VISIBILITY_ATTRIBUTE
#endif
// GCC 3.3 and later support the visibility attribute
#if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XPCOM_PLATFORM_OS2)
#  define XPCOM_USE_REGPARM_ATTRIBUTE
#endif

// Intel C++ before 8.0 ends up with unresolved externals unless we turn off
// extern template support
#if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800)
#  define XPCOM_NO_EXTERN_TEMPLATE
#endif
// Visual C++ doesn't support external templates with C++ extensions turned off
#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
#  define XPCOM_NO_EXTERN_TEMPLATE
#endif
// Turn off extern template for Borland C++
#if defined(__BORLANDC__)
#  if (__BORLANDC__ == 0x550) || (__BORLANDC__ == 0x551)
      // External templates cause problems for some reason
#     define XPCOM_NO_EXTERN_TEMPLATE
#  endif
#endif

// Disable warnings
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1310
// behavior change: an object of POD type constructed with an initializer of
// the form () will be default-initialized
#  pragma warning(disable: 4345)
// nonstandard extension used : 'extern' before template explicit instantiation
#  pragma warning(disable: 4231)
#endif // BOOST_MSVC

// Disable exception rethrow/catch for msvc < 7
#if defined(BOOST_MSVC) && BOOST_MSVC < 1300
#  define XPCOM_DISABLE_EXCEPTION_RETHROW_CATCH
#endif // BOOST_MSVC
